function gadgetLoad(){
  $('#spinner').hide();
}

function callTwitter(){
  var twitter_search_url = "http://search.twitter.com/search.json";
  var query_string = {'q':$('#query').val()}
  var url = twitter_search_url + "?" + $.param(query_string);
  var params = {}
  params[gadgets.io.RequestParameters.CONTENT_TYPE] = gadgets.io.ContentType.JSON
  $('#spinner').show('fast');
  gadgets.io.makeRequest(url,callback,params);
}

function callback(data){
  $('#spinner').hide();
  //alert(data);
  var entry_html = "";
  if(data.data && data.data.results){
    for(var x = 0; x < 5; x++){
      var e = data.data.results[x];
      entry_html = entry_html + "<div class='entry'>";
      entry_html = entry_html + "<div class='image'><img src='" + e.profile_image_url + "'/></div>";
      entry_html = entry_html + "<div class='author'>" + e.from_user + "</div>";
      entry_html = entry_html + "<div class='content'>" + e.text + "</div>";
      entry_html = entry_html + "</div>";
      entry_html = entry_html + "<br style='clear:both'/>";
      entry_html = entry_html + "<hr/>";
    }
    $('#entries').html(entry_html);
  }
}

gadgets.util.registerOnLoadHandler(gadgetLoad);

